<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body onload="startTime()">
    <!-- 时钟钟表 -->
    <p id="text"></p>
    <script>
        function startTime() {
            var today = new Date();
            var h = today.getHours();
            var m = today.getMinutes();
            var s = today.getSeconds();
            m = checktime(m);
            s = checktime(s);
            document.getElementById("text").innerHTML = h + ":" + m +":" + s;
            t = setTimeout(function(){startTime()},500);
        }
        function checktime(i) {
            if(i<10){
                i = "0" + i;
            }
            return i;
        }

    </script>
    
</body>
</html>